.. This file was automatically converted from MediaWiki syntax. If some markup is wrong, looks weird or doesn't make sense, feel free to fix it. Please remove this comment once this file was manually checked and no "strange ReST" artifacts remain. .. _embedding-with-runpanda3d: Embedding with RunPanda3D ========================= Using nested elements is a straightforward way to embed your p3d file, but it does have two disadvantages. Specifically, (1) it requires you to specify all of the options twice, which promotes errors; and (2) it doesn't work if you need to specify an "id" attribute to access your embedded plugin object via JavaScript, because you can't specify the same "id" attribute to two different elements. There's another alternative that solves both problems, using JavaScript. Of course, this requires that your end-users will have JavaScript enabled, but this is common; and your web page may have this requirement anyway if you are planning to control your p3d application via JavaScript. There's a JavaScript file called RunPanda3D.js that is distributed with the Panda3D source. You'll find it in the directory direct/src/directscripts. Simply copy this JavaScript file to your web host, and reference it in your web page like this: .. code-block:: html ... other head content ... ... other head content ... ... other body content ... ... other body content ... That is, you must include a reference to RunPanda3D.js within the ``part of your web page; and you include a call to the function`` P3D\_RunContent() within the part of your web page. P3D\_RunContent() will generate the appropriate form of the element for whichever browser the user is currently running: either the Internet Explorer form, or the non-Internet Explorer form. The object element is generated via document.write(), wherever the call to P3D\_RunContent() appears within your web page. The parameters to P3D\_RunContent() must be given in pairs: of each two parameters, the first parameter is the keyword, and the second parameter is the value. This is equivalent to a keyword="value" pair appearing in the element. For instance, the above call would generate an element something like this: .. code-block:: html (though it will also add either classid or type, according to the type of browser the user is running.) Using P3D\_RunContent() also adds two additional :ref:`splash-window-tags`, noplugin\_img and noplugin\_href. These tags are not available if you embed using the syntax directly.